package com.cbg.base.exception.handler;

import com.cbg.base.exception.MiException;
import com.cbg.base.utils.CodeMsg;
import com.cbg.base.utils.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <pre></pre>
 * <small> 2018-10-08 | chenbing </small>
 */
@ControllerAdvice(basePackages = "com.cbg")
public class MiExceptionHandler {
    @ResponseBody
    @ExceptionHandler(NullPointerException.class)
    Result<String> handelerNullPointException(NullPointerException e){
        return Result.build(CodeMsg.getCodeMsgByMsg(e.getMessage()));
    }

    @ResponseBody
    @ExceptionHandler(MiException.class)
    Result<String> handelerMiException(MiException e){
        return Result.build(CodeMsg.getCodeMsgByMsg(e.getMessage()));
    }
}
